<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    const socket = new WebSocket("ws://127.0.0.1:8081/LuLi/websocket/1");

    socket.onopen = function (event) {
        console.log("已连接到WebSocket服务");
        console.log("------:", event.data);
    };

    socket.onmessage = function (event) {
        console.log("---onmessage---:", event.data);
        // 可根据解析出的数据进行页面渲染等操作
    };

    socket.onclose = function (event) {
        console.log("与WebSocket服务断开连接");
    };
</script>
</body>
</html>